<template>
  <div class="wrap">
    <div class="header">
      <div class="head-picture"  :style="`background-image:url(${userInfo.headPicture})`"></div>
    </div>
    <div class="handle">
      <el-link type="warning" @click="logout">退出登录</el-link>
    </div>
    <div>
      <div class="line">
        <span class="key">用户：</span>
        <span class="value">{{ userInfo.userName }}</span>
      </div>
      <div class="line">
        <span class="key">昵称：</span>
        <span class="value">{{ userInfo.nickName }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { removeToken } from "utils/auth";
import request from "utils/request";
export default {
  name: "JddChromePluginsUserCenter",

  data() {
    return {
      userInfo: {},
    };
  },

  mounted() {
    this.getUserInfo();
  },

  methods: {
    async getUserInfo() {
      let ret = await request.get("/findUser");
      if (ret.data) {
        this.userInfo = ret.data;
      }
    },
    logout() {
      removeToken();
      this.$router.push({
        path: "/login",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.wrap {
  padding: 20px 15px;
}
.handle {
  text-align: center;
  margin-bottom: 15px;
}
.header {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
  .head-picture {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 1px sandybrown solid;
    overflow: hidden;
    // background-image: url("https://img2.baidu.com/it/u=4260305631,2279598204&fm=253&fmt=auto&app=138&f=JPEG?w=640&h=480");
    background-repeat: no-repeat;
    background-size: cover;
  }
}

.line {
  width: 100%;
  line-height: 45px;
  display: flex;
  font-size: 24px;
  .key {
    width: 50%;
    padding-right: 10px;
    text-align: right;
  }
  .value {
    width: 50%;
  }
}
</style>
